<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="com.zzty.springmybatis.entity.User"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet"
	href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
<script
	src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script
	src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ZZTY</title>
<!-- BOOTSTRAP STYLES-->
<link href="../css/bootstrap.css" rel="stylesheet" />

<!-- CUSTOM STYLES-->
<link href="../css/custom.css" rel="stylesheet" />
</head>

<script type="text/javascript">
	
<%-- <%User user = (User) request.getSession().getAttribute("user"); --%>
<%-- 			String img = (String) user.getImg();%> --%>
	$(document).ready(function() {

				$("#exampleInputFile").change(function() {
					var filepath = $("#exampleInputFile").val();
					var isnext = false;
					if (checkFile(filepath)) {
						isnext = true;
						$("#b1").removeAttr("disabled");
					}
					if (!isnext) {
						alert("不接受此文件类型！");
						$("#exampleInputFile").val("");
						$("#b1").attr("disabled","true");
						return false;
					}
				})

				$("#start").click(function() {
					$.get("../TeamExam/judgeStart", function(result) {
						if (result == "无法开始") {
							alert(result);
						} else {
							$("#start").hide();
							$("#question").show();
							var obj = JSON.parse(result);

							$("#company").val(obj.teamerId);
							$("#tarea1").val(obj.question);
							var count = obj.leftTime;
							var strs = new Array();
							strs = count.split("_");
							$("#t_h").html(strs[0]);
							$("#t_m").html(strs[1]);
							$("#t_s").html(strs[2]);
							setInterval(getTime, 1000);
							setInterval(refreshCount, 1000);
						}
					});
				})

				function checkFile(str) {
					var pos = str.lastIndexOf('.zip');
					if (pos === -1) {
						return false;
					} else {
						return pos + 4 === str.length;
					}
				}

				function getTime() {
					var date = new Date().toLocaleString();
					$("#time1").val(date);
				}

				function refreshCount() {
					if ($("#t_h").html() == "已") {
						return;
					}
					var hour = $("#t_h").html().charAt(0);
					var minute = $("#t_m").html().charAt(0)
							+ $("#t_m").html().charAt(1);
					var second = $("#t_s").html().charAt(0)
							+ $("#t_s").html().charAt(1);

					var t = (hour * 3600) + (minute * 60) + (second * 1) - 1;
					if (t <= 0) {
						$("#t_h").html("已");
						$("#t_m").html("结");
						$("#t_s").html("束");
					} else {
						var h = Math.floor(t / 60 / 60 % 24);
						var m = Math.floor(t / 60 % 60);
						var s = Math.floor(t % 60);

						$("#t_h").html(h + "时");
						if (m < 10) {
							m = "0" + m;
						}
						if (s < 10) {
							s = "0" + s;
						}
						$("#t_m").html(m + "分");
						$("#t_s").html(s + "秒");
					}
				}

			})
</script>
<head>

<meta charset=utf-8>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ZZTY</title>
<!-- BOOTSTRAP STYLES-->
<link href="../css/bootstrap.css" rel="stylesheet" />

<!-- CUSTOM STYLES-->
<link href="../css/custom.css" rel="stylesheet" />
</head>
<body>
	<div id="wrapper">
		<nav class="navbar navbar-default navbar-cls-top " role="navigation"
			style="margin-bottom: 0">
			<div class="navbar-header">
				<a class="navbar-brand">自在天原</a>
			</div>
			<div
				style="color: white; padding: 15px 50px 5px 50px; float: right; font-size: 16px;">
				<form action="../loginOut.jsp" method="post">
					<button type="submit" class="btn btn-danger">注销</button>
				</form>
			</div>
		</nav>
		<!-- /. NAV TOP  -->
		<nav class="navbar-default navbar-side" role="navigation">
			<div class="sidebar-collapse">
				<ul class="nav" id="main-menu">
<%-- 					<li class="text-center"><img src="<%=img%>" --%>
<!-- 						class="user-image img-responsive" /></li> -->

					<li><a href="../StudentPageSkip/index"><i
							class="fa fa-dashboard fa-3x"></i> 主页</a></li>
					<li><a href="../StudentPageSkip/UserInfo"><i class="fa fa-table fa-3x"></i>
							个人信息</a></li>
					<li><a href="../StudentPageSkip/SelfExam"><i class="fa fa-desktop fa-3x"></i>
							今日竞赛</a></li>
					<li><a href="../StudentPageSkip/TeamExam"><i class="fa fa-qrcode fa-3x"></i>
							今日结对</a></li>
					<li><a href="../StudentPageSkip/History"><i
							class="fa fa-bar-chart-o fa-3x"></i> 历史记录</a></li>

					<li><a href="../StudentPageSkip/ChangePassword"><i
							class="fa fa-edit fa-3x"></i> 密码修改 </a></li>


				</ul>

			</div>

		</nav>
		<!-- /. NAV SIDE  -->
		<div id="page-wrapper">
			<div id="page-inner">
				<div class="row">
					<div class="col-md-12">
						<h2>结对竞赛</h2>
						<h5></h5>

					</div>
				</div>
				<!-- /. ROW  -->
				<hr />
				<div class="container" id="question" style="display:none">
					<div class="container">
						<div class="row clearfix">
							<div class="col-md-6 column">
								<div class="row clearfix">
									<div class="col-md-12 column">
										<textarea id="tarea1" rows="30" cols="70" disabled>
									</textarea>
									</div>
								</div>
							</div>
							<div class="col-md-6 column">
								<h2>
									<span>你的队友为<input type="text" id="company"
										style="border: 0px; background: none;" disabled></input></span>
								</h2>
								<div style="padding: 100px 0px 10px;">
									<div>
										<h1>
											<span class="label label-info">当前时间</span><span
												class="label label-info"><input type="text"
												id="time1" style="border: 0px; background: none;" disabled></input></span>

										</h1>
									</div>
									<div>
										<h1>
											<div class="col-sm-offset-0 col-sm-12">
												<h3>
													<div id="CountMsg" class="HotDate">
														<span class="label label-info" id="t_d">00天</span> <span
															class="label label-info" id="t_h">00时</span> <span
															class="label label-info" id="t_m">00分</span> <span
															class="label label-info" id="t_s">00秒</span>
													</div>
												</h3>
											</div>
										</h1>
									</div>
								</div>
								<div style="padding: 100px 0px 10px;">
									<div class="col-md-6 column">
										<form id="form1" role="form" action="../TeamExam/uploadFile" method="post"
											enctype="multipart/form-data">
											<div class="form-group">
												<label for="exampleInputFile">文件上传</label><input type="file"
													id="exampleInputFile" name="filename" />
												<p class="help-block"></p>
											</div>
											<button type="submit" class="btn btn-default" id="b1" disabled="disabled">提交</button>
											<div>
												<input id="operation" style="display: none;"></input>
											</div>
										</form>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div style="padding: 300px 0px 10px;">
					<div class="container">
						<div class="row clearfix">
							<div class="col-md-4 column"></div>
							<div class="col-md-4 column">

								<button id="start" type="button"
									class="btn-block btn-lg btn-primary">开始</button>
							</div>
							<div class="col-md-4 column"></div>
						</div>
					</div>
				</div>
			</div>
			<!-- /. PAGE INNER  -->
		</div>


		<!-- /. PAGE WRAPPER  -->
	</div>
	<!-- /. WRAPPER  -->
	<!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
	<!-- JQUERY SCRIPTS -->
	<script src="../js/jquery-1.10.2.js"></script>
	<!-- BOOTSTRAP SCRIPTS -->
	<script src="../js/bootstrap.min.js"></script>
	<!-- METISMENU SCRIPTS -->
	<script src="../js/jquery.metisMenu.js"></script>
</body>
</html>
